package com.behome.web.controller.media;

import cn.hutool.core.io.FileUtil;
import cn.hutool.core.util.IdUtil;
import com.behome.common.annotation.Log;
import com.behome.common.core.controller.BaseController;
import com.behome.common.core.domain.AjaxResult;
import com.behome.common.core.page.TableDataInfo;
import com.behome.common.enums.BusinessType;
import com.behome.common.utils.DictUtils;
import com.behome.common.utils.file.FileUtils;
import com.behome.common.utils.file.VideoUtil;
import com.behome.system.domain.TMediaSource;
import com.behome.system.service.IMediaSourceService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import java.io.File;
import java.io.InputStream;
import java.io.OutputStream;
import java.nio.file.Files;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Objects;

/**
 * 媒资库
 *
 * @author behome
 */
@RestController
@Api(tags = "媒资审核")
@RequestMapping("/media/mediaReview")
public class MediaReviewController extends BaseController {
    @Resource
    private IMediaSourceService mediaSourceService;

    /**
     * 获取媒资分类列表
     */
    @PreAuthorize("@ss.hasPermi('media:mediaReview:list')")
    @ApiOperation("获取未审核媒资列表")
    @GetMapping("/list")
    public TableDataInfo list(TMediaSource mediaSource) {
        startPage();
        mediaSource.setUploadUser(getUserId());
        mediaSource.setRegionId(getRegionId());
        List<TMediaSource> list = mediaSourceService.selectMediaSourceList(mediaSource);
        return getDataTable(list);
    }

    @PostMapping("/auditActions")
    @PreAuthorize("@ss.hasPermi('media:mediaReview:auditActions')")
    @ApiOperation("媒资列表审核操作")
    public AjaxResult auditActions(@RequestBody TMediaSource mediaSource) {
        mediaSource.setReviewUser(getUserId());
        mediaSource.setReviewTime(new Date());
        return toAjax(mediaSourceService.update(mediaSource));
    }


}
